﻿using System;

namespace Aludra.Core.Models
{
    public class SpellTrapCard : ICard, IEquatable<SpellTrapCard>
    {
        #region ICard Memebers
        public string Id
        {
            get;
            protected set;
        }

        public string Name
        {
            get;
            protected set;
        }

        public CardType Type
        {
            get;
            set;
        }

        public string Description
        {
            get;
            protected set;
        }

        public Func<object> Execute
        {
            get;
            set;
        }

        public Func<bool> CanExecute
        {
            get;
            set;
        }

        #endregion

        #region Spell Card Members

        public SpellTrapType SpellTrapType
        {
            get;
            set;
        }

        #endregion

        public SpellTrapCard(string id, string name, string description, CardType cardType)
        {
            if (cardType != CardType.Spell && cardType != CardType.Trap)
            {
                throw new ArgumentException("Card type must be either Spell or Trap");
            }
            this.Id = id;
            this.Name = name;
            this.Description = description;
            this.Type = cardType;
            this.Execute = () => null;
            this.CanExecute = () => true;
        }

        public bool Equals(SpellTrapCard other)
        {
            if (other == null)
            {
                return false;
            }

            bool result = true;
            result &= (this.Name == other.Name);
            result &= (this.Description == other.Description);
            result &= (other.Type == CardType.Spell || other.Type == CardType.Trap);
            result &= (this.SpellTrapType == other.SpellTrapType);

            return result;
        }
    }
}
